home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / singleieee.asm < prev    next >
Assembly Source File  |  1990-04-07  |  4KB  |  176 lines

  1.  
  2.            INCLUDE "exec/types.i"
  3.            INCLUDE "exec/alerts.i"
  4.            INCLUDE "exec/nodes.i"
  5.            INCLUDE "exec/libraries.i"
  6.  
  7. *********************************************************************
  8.  
  9. xlib           macro
  10.            xref    _LVO\1
  11.            endm
  12.  
  13. callsys        macro
  14.            CALLLIB _LVO\1
  15.            endm
  16.  
  17. *********************************************************************
  18.  
  19.            xlib    IEEESPMul
  20.            xlib    IEEESPDiv
  21.            xlib    IEEESPAdd
  22.            xlib    IEEESPSub
  23.            xlib    IEEESPNeg
  24.            xlib    IEEESPTst
  25.            xlib    IEEESPCmp
  26.            xlib    IEEESPFlt
  27.            xlib    IEEESPInt
  28.            xlib    OpenLibrary
  29.            xlib    Alert
  30.  
  31.            xref    _exit
  32.            xref    _MathIeeeSingBasBase
  33.  
  34.                xref    .Fs2d
  35.                xref    .Fd2s
  36.                xref    .Fd2l
  37.                xref    .Fl2d
  38.  
  39.            SECTION 2,DATA
  40.  
  41. _MathIeeeSingBasBase dc.l 0
  42. MATHName       dc.b    'mathieeesingbas.library',0
  43.  
  44. *********************************************************************
  45. *
  46.            SECTION 1,CODE
  47.  
  48. *********************************************************************
  49. *
  50. *    Make sure the MathIeeeSingBasBase is loaded correctly
  51. *
  52.            XDEF    .FSopen
  53. .FSopen:
  54.            movem.l D0-D1/A0-A1,-(A7)         ; save registers
  55.            move.l  _MathIeeeSingBasBase,D0     ; Retrieve the library base
  56.            bne     Lopen1             ;
  57.                          ;
  58.            lea     MATHName,A1         ;   Load the name of library
  59.            moveq   #0,d0             ;   Any version will do...
  60.            move.l  4,A6             ;   Get exec base
  61.            callsys OpenLibrary         ;   Open the library
  62.            move.l  D0,_MathIeeeSingBasBase     ;   Save the return code
  63.            bne     Lopen1             ;   If non-zero then OK
  64.  
  65.            ALERT   (AG_OpenLib!AO_MathLib)   ;     Signal an error
  66.            pea     100             ;     push return code
  67.            jsr     _exit             ;     and exit
  68.            add.w   #4,A7             ;
  69. Lopen1:
  70.            move.l  D0,A6             ; Set A6 to be library base
  71.            movem.l (A7)+,D0-D1/A0-A1         ; restore temporaries
  72.            rts
  73.  
  74. *********************************************************************
  75. *
  76. *    Single multiply arguments are in D0,D1
  77. *
  78.            XDEF    .FSmul
  79. .FSmul:
  80.            movem.l A6,-(A7)
  81.            jsr     .FSopen
  82.            callsys IEEESPMul
  83.            movem.l (A7)+,A6
  84.            rts               ; return to caller
  85.  
  86. *********************************************************************
  87. *
  88. *    Single divide arguments are in D0,D1
  89. *
  90.            XDEF    .FSdiv
  91. .FSdiv:
  92.            movem.l A6,-(A7)
  93.            jsr     .FSopen
  94.            callsys IEEESPDiv
  95.            movem.l (A7)+,A6
  96.            rts               ; return to caller
  97.  
  98. *********************************************************************
  99. *
  100. *    Single add arguments are in D0,D1
  101. *
  102.            XDEF    .FSadd
  103. .FSadd:
  104.            movem.l A6,-(A7)
  105.            jsr     .FSopen
  106.            callsys IEEESPAdd
  107.            movem.l (A7)+,A6
  108.            rts               ; return to caller
  109.  
  110. *********************************************************************
  111. *
  112. *    Single subtract arguments are in D0,D1
  113. *
  114.            XDEF    .FSsub
  115. .FSsub:
  116.            movem.l A6,-(A7)
  117.            jsr     .FSopen
  118.            callsys IEEESPSub
  119.            movem.l (A7)+,A6
  120.            rts               ; return to caller
  121.  
  122. *********************************************************************
  123. *
  124. *    Single negate argument is in D0
  125. *
  126.            XDEF    .FSneg
  127. .FSneg:
  128.            movem.l A6,-(A7)
  129.            jsr     .FSopen
  130.            callsys IEEESPNeg
  131.            movem.l (A7)+,A6
  132.            rts               ; return to caller
  133.  
  134. *********************************************************************
  135. *
  136. *    Single compare arguments are in D0,D1
  137. *
  138.            XDEF    .FScmp
  139. .FScmp:
  140.            movem.l A6,-(A7)
  141.            jsr     .FSopen
  142.            callsys IEEESPCmp
  143.            movem.l (A7)+,A6
  144.            tst.l   D0
  145.            bne.s   Lcmps1
  146.            move.l  #0,D0
  147.            bra.s   Lcmps3
  148. Lcmps1
  149.            bmi.s   Lcmps2
  150.            move.l  #1,D0
  151.            bra.s   Lcmps3
  152. Lcmps2
  153.            move.l  #-1,D0
  154. Lcmps3
  155.            rts               ; return to caller
  156.  
  157. *********************************************************************
  158. *
  159. *    Convert long to single : Input in D0
  160. *
  161.     XDEF    .Fl2s
  162. .Fl2s:
  163.                jsr .Fl2d
  164.                jmp .Fd2s
  165.  
  166. *********************************************************************
  167. *
  168. *    Convert single to long : Input in D0
  169. *
  170.     XDEF    .Fd2l
  171. .Fs2l:
  172.                jsr .Fs2d
  173.                jmp .Fd2l
  174.  
  175.            END
  176.